#pragma once
#include <iostream>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
namespace myaddr
{
    class Addr
    {
    public:
        Addr(struct sockaddr_in addr) : _addr(addr)
        {
            _ip = inet_ntoa(_addr.sin_addr);
            _port = _addr.sin_port;
        }
        ~Addr() {}
        std::string GetString() const
        {
            return _ip + ":" + std::to_string(_port);
        }
        std::string Ip() { return _ip; }
        uint16_t Port() { return _port; }

    private:
        struct sockaddr_in _addr;
        std::string _ip;
        uint16_t _port;
    };
}